package com.huijie.core.util;

import java.util.regex.Pattern;

/**
 * @ClassName EpcUtil
 * @Description epc工具类
 * @Author Alex
 * @Date 2018/9/18 11:48
 * @Version 1.0
 */
public class EpcUtil {

    /**
     * epc正则表达式
     */
    private static final String EPC_REG = "^(2[0-9ABCDEF]{28}FFF|1[0-9ABCDEF]{26}F)$";
    private static final int EPC_LENGTH_MIN = 28;
    private static final int EPC_LENGTH_MAX = 32;

    public static boolean validEpc(String epc){
        int len = epc.length();
        boolean illegalLength = (len == EPC_LENGTH_MIN || len == EPC_LENGTH_MAX);
        return illegalLength && Pattern.matches(EPC_REG, epc);
    }
}
